package com.koron.order.experiment.bean.po;

import com.koron.order.common.bean.base.ButtonCode;
import com.koron.order.common.bean.base.ButtonUserType;
import com.koron.order.common.bean.base.JurisdictionUserType;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum ExperimentStatus {

    DRAFT("DRAFT", "草稿", 1),
    WAIT_DISPATCH("WAIT_DISPATCH", "待派工", 2),
    WAIT_EXECUTE("WAIT_EXECUTE", "待执行", 3),
    IN_EXECUTE("IN_EXECUTE", "执行中", 4),
    WAIT_REVIEW("WAIT_REVIEW", "待审核", 5),
    WAIT_ACCEPT("WAIT_ACCEPT", "待验收", 5),
    ARCHIVED("ARCHIVED", "已归档", 6);

    private String status;
    private String desc;
    private int sort;

    ExperimentStatus(String var1, String var2, int sort) {
        this.status = var1;
        this.desc = var2;
        this.sort = sort;
    }

    public String getStatus() {
        return status;
    }

    public String getDesc() {
        return desc;
    }

    public int getSort() {
        return sort;
    }

    public static ExperimentStatus getExperimentStatus(String status) {

        switch (status) {
            case "DRAFT":
                return DRAFT;
            case "WAIT_REVIEW":
                return WAIT_REVIEW;
            case "WAIT_DISPATCH":
                return WAIT_DISPATCH;
            case "WAIT_EXECUTE":
                return WAIT_EXECUTE;
            case "IN_EXECUTE":
                return IN_EXECUTE;
            case "WAIT_ACCEPT":
                return WAIT_ACCEPT;
            case "ARCHIVED":
                return ARCHIVED;
        }
        return null;
    }

    //获取与前端统一过的页面按钮编码
    public static Map<String, List<String>> getPageButtonCode(String status) {

        switch (status) {
            case "DRAFT":
                Map<String, List<String>> draft_cond = new HashMap<String, List<String>>();
                ButtonUserType.put(draft_cond, ButtonCode.save, JurisdictionUserType.creater,JurisdictionUserType.createOrg);
                ButtonUserType.put(draft_cond, ButtonCode.submit, JurisdictionUserType.creater,JurisdictionUserType.createOrg);
                ButtonUserType.put(draft_cond, ButtonCode.delete, JurisdictionUserType.creater,JurisdictionUserType.createOrg);
                return draft_cond;
            case "WAIT_DISPATCH":
                Map<String, List<String>> wait_dispatch_cond = new HashMap<String, List<String>>();
                ButtonUserType.put(wait_dispatch_cond, ButtonCode.save, JurisdictionUserType.createOrg);
                ButtonUserType.put(wait_dispatch_cond, ButtonCode.dispatch, JurisdictionUserType.createOrg);
                //ButtonUserType.put(wait_dispatch_cond, ButtonCode.invalid, JurisdictionUserType.createOrg);
                return wait_dispatch_cond;
            case "WAIT_EXECUTE":
                Map<String, List<String>> wait_execute_cond = new HashMap<String, List<String>>();
                ButtonUserType.put(wait_execute_cond, ButtonCode.execute, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(wait_execute_cond, ButtonCode.application, JurisdictionUserType.deptManageOrg);
                ButtonUserType.put(wait_execute_cond, ButtonCode.handleTicketWork, JurisdictionUserType.deptManageOrg, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(wait_execute_cond, ButtonCode.orderChange, JurisdictionUserType.createOrg);
                //ButtonUserType.put(wait_execute_cond, ButtonCode.invalid, JurisdictionUserType.createOrg);
                return wait_execute_cond;
            case "IN_EXECUTE":
                Map<String, List<String>> in_execute_cond = new HashMap<String, List<String>>();
                ButtonUserType.put(in_execute_cond, ButtonCode.save, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.addExecute, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.deleteExecute, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.finishWaitAccept, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.handleTicketWork, JurisdictionUserType.deptManageOrg, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.application, JurisdictionUserType.deptManageOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.concession, JurisdictionUserType.createOrg, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.question, JurisdictionUserType.createOrg, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                return in_execute_cond;
            case "WAIT_ACCEPT":
                Map<String, List<String>> wait_accept_cond = new HashMap<String, List<String>>();
                ButtonUserType.put(wait_accept_cond, ButtonCode.save, JurisdictionUserType.deptManageOrg);
                ButtonUserType.put(wait_accept_cond, ButtonCode.submit, JurisdictionUserType.deptManageOrg);
                return wait_accept_cond;
            default:
                return new HashMap<>();
        }

    }


}
